//
//  UTFastCounterHeaderView.swift
//  UniversalTool
//
//  Created by LGB on 2025/3/4.
//

import UIKit

class UTFastCounterHeaderView: UITableViewHeaderFooterView {
    
    @IBOutlet weak var numberLabel: UILabel!
    
    override func awakeFromNib() {
        super.awakeFromNib()
        layer.shouldRasterize = true
        layer.rasterizationScale = UIScreen.main.scale
    }
    
    @IBAction func didReduce(_ sender: UIButton) {
        let number = Int(numberLabel.text ?? "0") ?? 0
        if number > 0 {
            numberLabel.text = String(format: "%ld", number - 1)
        }
    }
    
    
    @IBAction func didAdd(_ sender: UIButton) {
        let number = Int(numberLabel.text ?? "0") ?? 0
        numberLabel.text = String(format: "%ld", number + 1)
    }
    
    @IBAction func didReReload(_ sender: UIButton) {
        numberLabel.text = "0"
        UIApplication.shared.keyWindow?.makeToast("已重置", position: .center)
    }
    
}
